<template>
  <div class="goods-tabs">
    <nav>
      <a
        :class="{active: activeName==='detail'}"
        href="javascript:;"
        @click="activeName='detail'"
      >商品详情</a>

      <a
        :class="{active: activeName==='comment'}"
        href="javascript:;"
        @click="activeName='comment'"
        >商品评价<span>(500+)</span>
      </a>
    </nav>
    <!-- 切换内容的地方 -->
    <!-- <GoodsTabsDetail v-if="activeName==='detail'"/> -->
    <!-- <GoodsTabsComment v-if="activeName==='comment'"/> -->
    <component :is="'goods-tabs-'+activeName"/>
  </div>
</template>
<script>
import { ref } from 'vue'
import GoodsTabsDetail from './goods-tabs-detail.vue'
import GoodsTabsComment from './goods-tabs-comment.vue'
export default {
  name: 'GoodsTabs',
  components: { GoodsTabsDetail, GoodsTabsComment },
  setup () {
    const activeName = ref('detail')

    return { activeName }
  }
}
</script>
<style scoped lang="less">
.goods-tabs {
  nav {
    height: 70px;
    line-height: 70px;
    display: flex;
    border-bottom: 1px solid #f5f5f5;
    a {
      padding: 0 40px;
      font-size: 18px;
      position: relative;
      > span {
        color: @priceColor;
        font-size: 16px;
        margin-left: 10px;
      }
      &:first-child {
        border-right: 1px solid #f5f5f5;
      }
      &.active {
        &::before {
          content: "";
          position: absolute;
          left: 40px;
          bottom: -1px;
          width: 72px;
          height: 2px;
          background: @xtxColor;
        }
      }
    }
  }
}
</style>
